#include <cmath>

const float sin_table[] = {
        0.000000, 0.007854, 0.015707, 0.023560, 0.031411, 0.039260, 0.047106,
        0.054950, 0.062791, 0.070627, 0.078459, 0.086286, 0.094108, 0.101924,
        0.109734, 0.117537, 0.125333, 0.133121, 0.140901, 0.148672, 0.156434,
        0.164187, 0.171929, 0.179661, 0.187381, 0.195090, 0.202787, 0.210472,
        0.218143, 0.225801, 0.233445, 0.241075, 0.248690, 0.256289, 0.263873,
        0.271440, 0.278991, 0.286525, 0.294040, 0.301538, 0.309017, 0.316477,
        0.323917, 0.331338, 0.338738, 0.346117, 0.353475, 0.360811, 0.368125,
        0.375416, 0.382683, 0.389928, 0.397148, 0.404344, 0.411514, 0.418660,
        0.425779, 0.432873, 0.439939, 0.446979, 0.453990, 0.460974, 0.467930,
        0.474856, 0.481754, 0.488621, 0.495459, 0.502266, 0.509041, 0.515786,
        0.522499, 0.529179, 0.535827, 0.542442, 0.549023, 0.555570, 0.562083,
        0.568562, 0.575005, 0.581413, 0.587785, 0.594121, 0.600420, 0.606682,
        0.612907, 0.619094, 0.625243, 0.631353, 0.637424, 0.643456, 0.649448,
        0.655400, 0.661312, 0.667183, 0.673013, 0.678801, 0.684547, 0.690251,
        0.695913, 0.701531, 0.707107, 0.712639, 0.718126, 0.723570, 0.728969,
        0.734323, 0.739631, 0.744894, 0.750111, 0.755282, 0.760406, 0.765483,
        0.770513, 0.775496, 0.780430, 0.785317, 0.790155, 0.794944, 0.799685,
        0.804376, 0.809017, 0.813608, 0.818150, 0.822641, 0.827081, 0.831470,
        0.835807, 0.840094, 0.844328, 0.848510, 0.852640, 0.856718, 0.860742,
        0.864713, 0.868632, 0.872496, 0.876307, 0.880063, 0.883766, 0.887413,
        0.891007, 0.894545, 0.898028, 0.901455, 0.904827, 0.908143, 0.911403,
        0.914607, 0.917755, 0.920845, 0.923880, 0.926857, 0.929776, 0.932639,
        0.935444, 0.938191, 0.940881, 0.943512, 0.946085, 0.948600, 0.951057,
        0.953454, 0.955793, 0.958073, 0.960294, 0.962455, 0.964557, 0.966600,
        0.968583, 0.970506, 0.972370, 0.974173, 0.975917, 0.977600, 0.979223,
        0.980785, 0.982287, 0.983729, 0.985109, 0.986429, 0.987688, 0.988886,
        0.990024, 0.991100, 0.992115, 0.993068, 0.993961, 0.994792, 0.995562,
        0.996270, 0.996917, 0.997503, 0.998027, 0.998489, 0.998890, 0.999229,
        0.999507, 0.999722, 0.999877, 1.000000};

const float cos_table[] = {
        1.000000, 0.999969, 0.999877, 0.999722, 0.999507, 0.999229, 0.998890,
        0.998489, 0.998027, 0.997503, 0.996917, 0.996270, 0.995562, 0.994792,
        0.993961, 0.993068, 0.992115, 0.991100, 0.990024, 0.988886, 0.987688,
        0.986429, 0.985109, 0.983729, 0.982287, 0.980785, 0.979223, 0.977600,
        0.975917, 0.974173, 0.972370, 0.970506, 0.968583, 0.966600, 0.964557,
        0.962455, 0.960294, 0.958073, 0.955793, 0.953454, 0.951057, 0.948600,
        0.946085, 0.943512, 0.940881, 0.938191, 0.935444, 0.932639, 0.929776,
        0.926857, 0.923880, 0.920845, 0.917755, 0.914607, 0.911403, 0.908143,
        0.904827, 0.901455, 0.898028, 0.894545, 0.891007, 0.887413, 0.883766,
        0.880063, 0.876307, 0.872496, 0.868632, 0.864713, 0.860742, 0.856718,
        0.852640, 0.848510, 0.844328, 0.840094, 0.835807, 0.831470, 0.827081,
        0.822641, 0.818150, 0.813608, 0.809017, 0.804376, 0.799685, 0.794944,
        0.790155, 0.785317, 0.780430, 0.775496, 0.770513, 0.765483, 0.760406,
        0.755282, 0.750111, 0.744894, 0.739631, 0.734323, 0.728969, 0.723570,
        0.718126, 0.712639, 0.707107, 0.701531, 0.695913, 0.690251, 0.684547,
        0.678801, 0.673013, 0.667183, 0.661312, 0.655400, 0.649448, 0.643456,
        0.637424, 0.631353, 0.625243, 0.619094, 0.612907, 0.606682, 0.600420,
        0.594121, 0.587785, 0.581413, 0.575005, 0.568562, 0.562083, 0.555570,
        0.549023, 0.542442, 0.535827, 0.529179, 0.522499, 0.515786, 0.509041,
        0.502266, 0.495459, 0.488621, 0.481754, 0.474856, 0.467930, 0.460974,
        0.453990, 0.446979, 0.439939, 0.432873, 0.425779, 0.418660, 0.411514,
        0.404344, 0.397148, 0.389928, 0.382683, 0.375416, 0.368125, 0.360811,
        0.353475, 0.346117, 0.338738, 0.331338, 0.323917, 0.316477, 0.309017,
        0.301538, 0.294040, 0.286525, 0.278991, 0.271440, 0.263873, 0.256289,
        0.248690, 0.241075, 0.233445, 0.225801, 0.218143, 0.210472, 0.202787,
        0.195090, 0.187381, 0.179661, 0.171929, 0.164187, 0.156434, 0.148672,
        0.140901, 0.133121, 0.125333, 0.117537, 0.109734, 0.101924, 0.094108,
        0.086286, 0.078459, 0.070627, 0.062791, 0.054950, 0.047106, 0.039260,
        0.031411, 0.023560, 0.015707, 0.000000};

double find_sin(double theta) {
    double symbol = 1;
    if (theta > 2 * M_PI) {
        // 大于2pi
        theta -= 2 * M_PI;
    } else if (theta < 0) {
        // 小于0
        theta += 2 * M_PI;
    }

    if (theta > M_PI_2 && theta <= M_PI) {
        // pi/2 ~ pi
        theta = M_PI - theta;
        symbol = 1;
    } else if (theta > M_PI && theta <= 1.5 * M_PI) {
        // pi ~ 3/2 * pi
        theta = theta - M_PI;
        symbol = -1;
    } else if (theta > 1.5 * M_PI && theta <= 2 * M_PI) {
        // 3/2 *pi ~ 2pi
        theta = 2 * M_PI - theta;
        symbol = -1;
    } else {
        // 0 ~ pi / 2
        theta = theta;
        symbol = 1;
    }

    theta = theta * 200 / M_PI_2;
    int theta_temp = static_cast<int>(theta);
    if (theta - theta_temp >= 0.5) {
        theta = theta_temp + 1;
    } else {
        theta = theta_temp;
    }
    if (theta < 1) {
        theta = 0;
    }
    if (theta > 199) {
        theta = 199;
    }
    return symbol * sin_table[static_cast<int>(theta)];
}

double find_cos(double theta) {
    // 标记正负号
    double symbol = 1;
    if (theta > 2 * M_PI) {
        // 大于2pi
        theta -= 2 * M_PI;
    } else if (theta < 0) {
        // 小于0
        theta += 2 * M_PI;
    }

    if (theta > M_PI_2 && theta <= M_PI) {
        // pi/2 ~ pi
        theta = M_PI - theta;
        symbol = -1;
    } else if (theta > M_PI && theta <= 1.5 * M_PI) {
        // pi ~ 3/2 * pi
        theta = theta - M_PI;
        symbol = -1;
    } else if (theta > 1.5 * M_PI && theta <= 2 * M_PI) {
        // 3/2 *pi ~ 2pi
        theta = 2 * M_PI - theta;
        symbol = 1;
    } else {
        // 0 ~ pi / 2
        theta = theta;
        symbol = 1;
    }
    theta = theta * 200 / M_PI_2;

    // (0~0.5) 舍1，（0.5~1）进1
    int theta_temp = static_cast<int>(theta);
    if (theta - theta_temp >= 0.5) {
        theta = theta_temp + 1;
    } else {
        theta = theta_temp;
    }
    if (theta < 1) {
        theta = 0;
    }
    if (theta > 199) {
        theta = 199;
    }

    return symbol * cos_table[static_cast<int>(theta)];
}

double ty_sin(double x) {
    return x - x * x * x /6+ x * x * x * x * x/120;
}